<?php

/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('login',['as' => 'admin.login','uses' => 'Admin\AuthController@login']);//登录
Route::post('login',['as' => 'admin.dologin','uses' => 'Admin\AuthController@doLogin']);//执行登录
Route::get('logout',['as' => 'admin.logout','uses' => 'Admin\AuthController@logout']);//退出登录

Route::get('404',['as' => 'admin.error.404','uses' => 'Admin\ErrorController@error404Action']);//404
Route::get('500',['as' => 'admin.error.500','uses' => 'Admin\ErrorController@error500Action']);//500
 
//已登录路由
Route::group(['middleware' => ['adminAuthenticate']],function() {
    Route::group(['namespace' => 'Admin'], function () {
        Route::get('/', 'IndexController@indexAction');
        Route::get('/clearRedis', 'IndexController@clearRedis');
    });

    //用户管理
    Route::group(['prefix' => 'user', 'namespace' => 'Admin\User'], function () {
        Route::get('/', ['as' => 'foradmin.user','uses' => 'UserController@indexAction']);
        Route::get('/{id}', ['as' => 'user.show','uses' => 'UserController@showAction']);
        Route::get('/{id}/edit', 'UserController@updateAction');
        Route::put('/{id}/edit', 'UserController@updateAction');
        Route::delete('/{id}', 'UserController@deleteAction');
    });

    //公司管理
    Route::group(['prefix' => 'company', 'namespace' => 'Admin\User'], function () {
        Route::get('/', 'CompanyController@indexAction');
        Route::get('/{id}', 'CompanyController@showAction');
        Route::get('/{id}/edit', 'CompanyController@updateAction');
        Route::post('/{id}/edit', 'CompanyController@updateAction');
        Route::delete('/{id}', 'CompanyController@deleteAction');
    });

    //认证列表
    Route::group(['prefix' => 'authentication', 'namespace' => 'Admin\User'], function () {
        Route::get('/', 'AuthenticationController@indexAction');
        Route::get('/{id}', 'AuthenticationController@showAction');
        Route::get('/{id}/edit', 'AuthenticationController@updateAction');
        Route::put('/{id}/edit', 'AuthenticationController@updateAction');
        Route::delete('/{id}', 'AuthenticationController@deleteAction');
    });
    
    //店铺模块
    Route::group(['prefix' => 'shop', 'namespace' => 'Admin\Shop'], function () {
        Route::get('/', 'ShopController@indexAction');
        Route::get('/add', 'ShopController@addAction');
        Route::get('/edit', 'ShopController@editAction');
        Route::post('/', 'ShopController@updateAction');
        Route::get('/delete', 'ShopController@deleteAction');
        Route::put('/recommend/{id}', 'ShopController@recommend');//店铺推荐


        Route::get('/sp_type', 'ShopTypeController@indexAction');
        Route::post('/sp_type/add', 'ShopTypeController@createAction');
        Route::put('/sp_type/{id}/edit', 'ShopTypeController@updateAction');
        Route::delete('/sp_type/{id}/delete', 'ShopTypeController@deleteAction');

        Route::get('/level', 'ShopLevelController@indexAction');
        Route::post('/level/add', 'ShopLevelController@createAction');
        Route::put('/level/{id}/edit', 'ShopLevelController@updateAction');
        Route::delete('/level/{id}/delete', 'ShopLevelController@deleteAction');
    });

    //产品模块
    Route::group(['prefix' => 'product', 'namespace' => 'Admin\Product'], function () {
        Route::get('/', 'ProductController@indexAction');
        Route::get('/{id}', 'ProductController@showAction')->where('id', '[0-9]+');
        Route::post('/add', 'ProductController@storeAction');
        Route::put('/{id}/edit', 'ProductController@updateAction');
        Route::put('/{id}/ajaxupdate', 'ProductController@ajaxUpdateAction');
        Route::delete('/{id}/delete', 'ProductController@deleteAction');
        Route::post('/{id}/recommend', 'ProductController@ajaxRecommend');
        
        Route::post('/batchstatus', 'ProductController@ajaxBatchStatusAction');
        

        Route::get('/cate/', 'CategoryController@indexAction');
        Route::get('/cate/{id}', 'CategoryController@showAction');
        Route::post('/cate/add', 'CategoryController@storeAction');
        Route::put('/cate/{id}/edit', 'CategoryController@updateAction');
        Route::delete('/cate/{id}/delete', 'CategoryController@deleteAction');
        Route::post('/cate/{id}/recommend', 'CategoryController@ajaxRecommend');
        Route::post('/cate/{id}/shopindex_recommend', 'CategoryController@ajaxShopIndexRecommend');
        Route::post('/cate/{id}/showstatus', 'CategoryController@ajaxShowstatus');
        
        Route::get('/brand/', 'BrandController@indexAction');
        Route::get('/brand/{id}', 'BrandController@showAction');
        Route::post('/brand/add', 'BrandController@storeAction');
        Route::put('/brand/{id}/edit', 'BrandController@updateAction');
        Route::delete('/brand/{id}/delete', 'BrandController@deleteAction');

        Route::get('/attr/', 'AttributeController@indexAction');
        Route::get('/attr/vals/{id}', 'AttributeController@ajaxValuesAction');
        Route::get('/attr/{id}', 'AttributeController@showAction');
        Route::post('/attr/add', 'AttributeController@storeAction');
        Route::put('/attr/{id}/edit', 'AttributeController@updateAction');
        Route::put('/attr/{id}/ajaxupdate', 'AttributeController@ajaxUpdateAction');
        Route::delete('/attr/{id}/delete', 'AttributeController@deleteAction');
        
        Route::get('/attr_val/', 'AttributeValueController@indexAction');
        Route::get('/attr_val/{id}', 'AttributeValueController@showAction');
        Route::post('/attr_val/add', 'AttributeValueController@storeAction');
        Route::put('/attr_val/{id}/edit', 'AttributeValueController@updateAction');
        Route::put('/attr_val/{id}/ajaxupdate', 'AttributeValueController@ajaxUpdateAction');
        Route::delete('/attr_val/{id}/delete', 'AttributeValueController@deleteAction');
        
    });

    //订单管理
    Route::resource('order', 'Admin\Order\OrderController');
    // 项目信息管理
    Route::resource('project', 'Admin\Project\ProjectController');
    Route::group(['prefix' => 'project', 'namespace' => 'Admin\Project'], function () {
        Route::post('setCheckStatus/{id}', 'ProjectController@setCheckStatus');
    });
    //服务订单管理
    Route::resource('service', 'Admin\Service\ServiceOrderController');

    //订单评价
    Route::resource('order_product_comment', 'Admin\Order\OrderProductCommentController');

    //退单管理
    Route::group(['prefix' => 'change', 'namespace' => 'Admin\Change'], function () {
        Route::get('/', 'ChangeController@indexAction');//退单列表
    });
    //举报管理
    Route::group(['prefix' => 'report', 'namespace' => 'Admin\Report'], function () {
        Route::get('/', 'ReportController@indexAction');//举报列表
        Route::put('/', 'ReportController@updateAction');//更新状态
        Route::get('/type', 'TypeController@indexAction');//举报类型列表
        Route::post('/type', 'TypeController@createAction');//创建举报类型
        Route::post('/type/del', 'TypeController@deleteAction');//删除举报类型

    });


    //角色管理
    Route::resource('role','Admin\RoleController');

    //菜单管理
    Route::resource('menu','Admin\MenuController');
    Route::post('menu/checkRoute','Admin\MenuController@checkRoute');

    //系统用户
    Route::resource('adminuser','Admin\AdminuserController');

    //权限管理
    Route::resource('permission','Admin\PermissionController');

    //操作管理
    Route::resource('action','Admin\ActionController');
    
    //文章/文章分类管理
    Route::group(['prefix' => 'article', 'namespace' => 'Admin\Article'], function () {
        Route::resource('category','ArticleCategoryController');
        Route::post('category/setShow/{id}','ArticleCategoryController@setShow');
    });

    //文章管理
    Route::group(['namespace' => 'Admin\Article'], function () {
        Route::resource('article', 'ArticleController');
        Route::put('/article/audit/{id}', 'ArticleController@audit');//文章展示
        Route::get('/article/create', 'ArticleController@create');//文章添加
        Route::put('/article/recommend/{id}', 'ArticleController@recommend');//文章推荐
        Route::get('/article/categoryfid/{id}', 'ArticleController@categoryfid');//文章子分类

    });


    //广告位置管理
    Route::group(['namespace' => 'Admin\Advertisement'], function () {
        Route::resource('/advertisingposition','AdvertisingPositionController');
        Route::post('/advertisingposition/setShow/{id}','AdvertisingPositionController@setShow');
    });

    //广告列表管理
    Route::group(['namespace' => 'Admin\Advertisement'], function () {
        Route::resource('advertisinglist', 'AdvertisingListController');
        Route::put('/advertisinglist/audit/{id}', 'AdvertisingListController@audit');//广告展示
        //Route::get('/advertisinglist/create', 'AdvertisingListController@create');//广告添加
        Route::put('/advertisinglist/recommend/{id}', 'AdvertisingListController@recommend');//广告推荐

    });



    // IM 用户管理
    Route::group(['namespace' => 'Admin\Im'], function () {
        Route::resource('record','ImRecordController');
        Route::resource('im','ImController');
    });
    // 考察预约管理
    Route::group(['namespace' => 'Admin\GuestBook'], function () {
        Route::resource('guestbook','GuestBookController');
    });


});
